package spring.transaction.c01;


import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;

public class TranServiceImpl implements TranService {

	private JdbcTemplate jdbcTemplate;
	
	public void getPerson() {
		System.out.println("getPerson");
		throw new UnsupportedOperationException();
	}

	public String insertPerson(String s) throws Exception{
		final String sql="insert into t_person (name) values('shaorong')";
		
		jdbcTemplate.update(sql);
//		PlatformTransactionManager
		if(null==s||"".equals(s)){
			throw new Exception();
		}
		
		return "test ok";
	}

	public void updatePerson() {
		System.out.println("updatePerson");
		throw new UnsupportedOperationException();
	}

	public void getPersons() {
		System.out.println("getPersons");
	}

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}


}
